package com.customers.controller;

import com.alibaba.fastjson2.JSON;
import com.customers.entity.MainForm;
import com.customers.service.CustomerService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;

@WebServlet("/editForm")
public class EditFormServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String mainForm = request.getParameter("MainForm");
        MainForm form  = JSON.parseObject(mainForm,MainForm.class);
        try {
            CustomerService customerService = (CustomerService) request.getServletContext().getAttribute("CustomerService");
            String sql = "customerUp";
            customerService.editForm(form,sql);
//            EditFormService.editForm(form);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}
